package bingo.modelo;
	import java.util.*;   
	import java.security.*;   
	  
	public class BingoModelo implements BingoInterface
	{   	
		public static int count = 0;
		private int index = -1;
		private boolean sorteando = false;
		private Random random         = new SecureRandom();
		private List<Integer> numeros = new ArrayList<Integer>();	
		
		public BingoModelo(){				    
		    for(int i = 1; i <= 75; i++)
		    {
		    	numeros.add (new Integer (i));	    		
		    }
		    Collections.shuffle(numeros, random);
		}
		
		public void iniciarSorteio(){
			sorteando = true;
		    for(int i: numeros)
		    {		    	
		    	if (!sorteando) break;	    	
		    	index = i;
		    	//System.out.printf ("%02d ", i);
		    	try
		    	{		    		
		    		Thread.sleep(1000);		    		
		    	}catch(Exception e)
		    	{
		    		e.printStackTrace();
		    	}
		    }
	    }   
		
		public void pararSorteio(){
			sorteando = false;
		}

		public int[][] getQuadroDeBolas() {	
			int num =0;
	        int[][] quadroDeBolas = new int[8][10];//{{1, 2, 3, 4}, {5, 6, 7, 8}, {9, 10, 11, 12}};
	        for(int i = 0; i < 8; i++)
	        	for(int j = 0; j < 10; j++)
	        		if (i < 8)
	        			quadroDeBolas[i][j]=++num;
	        		else
	        			if (j < 5)
	        				quadroDeBolas[i][j]=++num;
	        return quadroDeBolas;
			//return null;
		}

		public int[] getUltimasBolas() {
			count++;
	        int[] ultimasBolas = new int[count];
	        for (int j=0;j<count;j++) ultimasBolas[j]=numeros.get(j);
	        return ultimasBolas;
			//return null;
		}

		public boolean sorteado(int bola) {
			for(int i=0 ;i < count; i++)
			{
				if(numeros.get(i) == bola)
					return true;
			}
			
			return false;	        
		}
}  
